package edu.online.dal;

import edu.online.entity.LessonScheduleEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface LessonScheduleEntityMapper {
    @Delete({
        "delete from lessonschedule",
        "where LessonScheduleID = #{lessonscheduleid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String lessonscheduleid);

    @Insert({
        "insert into lessonschedule (LessonScheduleID, LessonID, ",
        "UserId, SeqNo, LessonTime, ",
        "Status, LeaveID, SwitchID, ",
        "NewLessonTime, Comment)",
        "values (#{lessonscheduleid,jdbcType=CHAR}, #{lessonid,jdbcType=CHAR}, ",
        "#{userid,jdbcType=CHAR}, #{seqno,jdbcType=SMALLINT}, #{lessontime,jdbcType=TIMESTAMP}, ",
        "#{status,jdbcType=VARCHAR}, #{leaveid,jdbcType=CHAR}, #{switchid,jdbcType=CHAR}, ",
        "#{newlessontime,jdbcType=TIMESTAMP}, #{comment,jdbcType=VARCHAR})"
    })
    int insert(LessonScheduleEntity record);

    @InsertProvider(type=LessonScheduleEntitySqlProvider.class, method="insertSelective")
    int insertSelective(LessonScheduleEntity record);

    @Select({
        "select",
        "LessonScheduleID, LessonID, UserId, SeqNo, LessonTime, Status, LeaveID, SwitchID, ",
        "NewLessonTime, Comment",
        "from lessonschedule",
        "where LessonScheduleID = #{lessonscheduleid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="LessonScheduleID", property="lessonscheduleid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="LessonID", property="lessonid", jdbcType=JdbcType.CHAR),
        @Result(column="UserId", property="userid", jdbcType=JdbcType.CHAR),
        @Result(column="SeqNo", property="seqno", jdbcType=JdbcType.SMALLINT),
        @Result(column="LessonTime", property="lessontime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="Status", property="status", jdbcType=JdbcType.VARCHAR),
        @Result(column="LeaveID", property="leaveid", jdbcType=JdbcType.CHAR),
        @Result(column="SwitchID", property="switchid", jdbcType=JdbcType.CHAR),
        @Result(column="NewLessonTime", property="newlessontime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="Comment", property="comment", jdbcType=JdbcType.VARCHAR)
    })
    LessonScheduleEntity selectByPrimaryKey(String lessonscheduleid);

    @UpdateProvider(type=LessonScheduleEntitySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(LessonScheduleEntity record);

    @Update({
        "update lessonschedule",
        "set LessonID = #{lessonid,jdbcType=CHAR},",
          "UserId = #{userid,jdbcType=CHAR},",
          "SeqNo = #{seqno,jdbcType=SMALLINT},",
          "LessonTime = #{lessontime,jdbcType=TIMESTAMP},",
          "Status = #{status,jdbcType=VARCHAR},",
          "LeaveID = #{leaveid,jdbcType=CHAR},",
          "SwitchID = #{switchid,jdbcType=CHAR},",
          "NewLessonTime = #{newlessontime,jdbcType=TIMESTAMP},",
          "Comment = #{comment,jdbcType=VARCHAR}",
        "where LessonScheduleID = #{lessonscheduleid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(LessonScheduleEntity record);
}